C/C++ Platform

The C/C++ platform allows you to directly test C code from source files by automatically generating an appropriate test frame for the system under test. Furthermore, you can import functions and globally defined variables to TPT from the C code.

C/C++ Platform configuration

For information concerning the Custom Script Execution, see Custom Script Execution.

In case an execution error with a system error code occurs during test execution, check here for details: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55.

VM settings

Specify the Step size, Timeout and the History size.

Enforce single threaded execution

Enable this option to prohibit concurrent execution. Even if multiple cores are enabled in the Execution Configuration dialog. Some external resources do not allow parallel execution.

Source settings

Compiler

Choose a compiler from the drop-down list. Select Compile as 64 bit if you want to compile your code as 64-bit instead of 32-bit.

Project root folder

Specify the directory where your source files are located. All source files, includes and libraries have to be located below this directory.

Source

Click to select a C file. To select multiple C files in different folders in one step, click .
The order of the source files can be changed via .

Extra Options

Add compile flags if necessary. These flags are only valid for the source file they are assigned to.

Analyze

The original file is inserted into a second file that adds the connection to TPT. This happens via #include statement. Without instrumentation or access to function local variables the original source is included, otherwise an instrumented copy of the code is included, see TASMO instrumentation.

Headers

Click to open a user interface that allows you to insert header files. The headers will be included via compiler command when the associated files are being parsed or compiled.

A2L interface file

Select an A2L file to import additional information for variables that are specified in the C\C++ code. In case a variable in the A2L file has the same name as a variable in the C code files, the information of the variable defined in the A2L file will be imported. If this variable is a parameter and only declared as external variable, the default value will be 0 and the exchange mode will be set to writeonly.

Analyze sources

Allows you to import functions and variables from the C code files and additionally from an A2L file to TPT. Click the button to see a list of all variables and functions available in the C code files. The variables and functions of each C code file are shown independently.

You either need at least one function, or an instance of a class containing public functions. If neither one of them exist, you have to write a wrapper-code, see C Platform - Custom Wrapper Code

By default, all non-static variables are set to "connect", which means that they will be available in TPT. Static variables are set to "ignore", which means that they will not be used in TPT. Variables declared as extern will be connected if they are used. This means that they are available in TPT and that they will be declared by the generated test frame.

By default, functions will be scheduled by the generated testframe if they are unused and the implementation was found. If a function is used but no implementation was found by default the function will be stubbed by TPT. The call will be forwarded to a server function in TPT. Other functions will be ignored by default. There is also the possibility to connect implemented functions as client-function. This will generate a client-function in TPT which can be called from your TPT test cases. Not implemented (unresolved) functions can be set to "stubbed by TPT" to stub them by your TPT model, to "empty stub" to generate an empty implementation or to "schedule" if the implementation is provided but not found in the C code, for example if the function is within a library.

If the file is C++ code and contains class instances, public variables and functions of those instances can be connected to TPT like variables and functions outside of classes. By default, within new projects variables of any class instance will be connected to TPT, and unused class functions will be scheduled by TPT. On reimporting the code added variables within the class instance will not be considered by default.

Variables and functions of certain instances are represented as shown below:
nameofinstance::nameoffunction
nameofinstance::nameofvariable

Select functions and variables to connect to TPT

Use the following buttons to filter variables or functions:

Show static objects
Show/hide channels
  Global Show global variables
  Function intern Show function internal variables
Show functions
Show unused objects
  Resolved show unused resolved objects:
resolved objects are functions with a known implementation and variables with declaration that is not external
  Unresolved show unused, unresolved objects:
unresolved objects are functions that are declared but not implemented or variables tagged as external but without full declaration

It is possible to assign channel names to the arguments of scheduled functions. By default, the name is set to <argumentName>.

By opening an existing TPT project from older TPT versions the name is set to <functionName>_<argumentName> to avoid name conflicts.

It is possible to manually change channel names for arguments by double-clicking on a scheduled function, see (1) in Figure " Select functions and variables to connect to TPT". Functions using the same argument name with the same data type will be connected to TPT with a shared channel.

Function-internal variables can also be connected to TPT. They appear as children of functions within the sources interface. They can only be connected as TPT input. The variables´ value will be copied at the end of the associated block.

Custom Wrapper Code

Variables or functions specified in the Custom Wrapper Code editor are listed, see (2) in Figure " Select functions and variables to connect to TPT". They are used for the connection of the C code to the test object (SUT).

Unresolved references

External variables

If you have specified external variables that are not defined in the C code files, these are listed under unresolved references. Select connect, to define them and import them as output channels or import channels.

Unimplemented functions

In case not implemented functions were detected, these are listed as well.

ignore ->default; the function and its arguments will not be imported

stubbed by TPT -> the function will be added as server function and its arguments will be imported as local channels. The function call will be redirected to the server function.

schedule->the function is not imported but the arguments of the scheduled function will be imported as output channels; the function is called in each cycle using the imported channels as arguments

empty stub -> an empty stub is created instead of importing the function and its arguments; the empty stub will always return objects with all fields set to 0

Click Import interface to start the interface import, see also Declarations - Import Interface.

Extract interface of the C/C++ platform

Pointer variables are being imported as scalar variables. If you want to implement them as an array, you manually have to change the declaration of the variables. Changes in the declarations require to generate the test frame again.
Default values can be imported for none-pointer variables only.

Data types or variables used in C code files that do not conform to the TPT naming conventions are legalized by adding two underscores, for example __str or __abs, see Figure " Legalized variables and data types". Additionally, a mapping with Rename flavor is added, see Mapping Flavor - Rename.

Legalized variables and data types

Functions listed in Schedule will be updated in the Source settings section. You will be informed about any update made.
If the return type of a function is not supported, the type will be handled as void. This means the function can still be connected but the return value will be ignored by TPT.

Show code interface

(read-only) Click to display a list of all functions and variables from the C code and the setting you have applied.

Ignore includes

Variables that are included via the preprocessor directive #include will be imported by TPT. If you want to ignore them, select Ignore includes.

Test driver generation

Test driver generation with C Platform settings

Mapping

Select a mapping from the drop-down list to use its scaling and rename settings. The mapping list shows the mappings available in your current TPT project.

TASMO instrumentation

If you want to use TASMO for C to generate test data you need to either choose Coverage Measurement or Full Instrumentation, see also TASMO - Test Data Generator.

None

There will be no instrumentation

Coverage Measurement

Instrumentation for coverage measurement only; test data generation with TASMO will not be available

Full Instrumentation

Required for test data generation with TASMO

Test driver I/O

Enable Read/Write for output channels

Select this check box if you want to enable the system under test to read and write to channels specified as output channels in TPT when you generate and compile the test driver.

In case of arguments of scheduled functions this option only works with pointer or array types.

Include I/O consistency check

Select this check box to add tpt_vmapi_bindSignalFinalize() call to the generated test driver in order to test if all signals from TPT are connected to variables in the C code.

Initialize interface variables with pointer types in C

Select this check box to generate code to allocate the required memory for uninitialized pointer variables that are connected to TPT.

Round scaling results

Select this check box to round the scaling result to the nearest scaled value - up or down. Deselect this check box to round it down to the nearest smaller value.

Output directory

Specify the output directory all files generated by TPT shall be located in.

When you want to compile the same source code with different instrumentation settings, the compiled code needs to be saved in a different output location. Click to either select an existing folder or create a new one.

Generate and Compile test driver

Click the button to

The button Generate and Compile test driver is disabled as long as warnings are displayed in the Platform Configuration dialog.

For each configured source file where the Option Analyze is selected TPT will generate a new source file named:

that will include the original via a preprocessor directive.

In case the original code of a configured source file (or any included header) needs to be patched by TPT (for example, due to instrumentation for TASMO or for connecting function-local variables) TPT will create a modified copy of that file that then will be used instead of the original.

In case the original code does not need to be patched and there already is a modified version of that file within the output folder (from a previous test driver generation with different settings) this file will be deleted. This is to avoid that outdated files being used by the compiler by mistake.

Deactivated button due to incorrect or incomplete entries